import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from '@/views/Login.vue'
import Home from '@/views/Home.vue'
import Echart from '@/views/echart/index.vue'
import Menu from '@/views/menu/Menu.vue'
import Role from '@/views/role/index.vue'
import User from '@/views/user/index.vue'
import Category from '@/views/category/index.vue'
import Goods from '@/views/goods/index.vue'
import Specs from '@/views/specifications/index.vue'
Vue.use(VueRouter)
// 重写push和replace
const originPush = VueRouter.prototype.push
const originReplace = VueRouter.prototype.replace
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject)
  } else {
    originPush.call(this, location, () => { }, () => { })
  }
}
VueRouter.prototype.replace = function (location, resolve, reject) {
  if (resolve && reject) {
    originReplace.call(this, location, resolve, reject)
  } else {
    originReplace.call(this, location, () => { }, () => { })
  }
}

const routes = [
  // {
  //   path: '/login',
  //   component: Login,
  //   meta: {
  //     title: '欢迎登录'
  //   }
  // },
  {
    path: '/',
    component: Home,
    children: [
      { path: '', component: Echart },
      { path: 'menu', component: Menu },
      { path: 'role', component: Role },
      { path: 'user', component: User },
      { path: 'category', component: Category },
      { path: 'specs', component: Specs },
      { path: 'goods', component: Goods }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
